package com.example.helloworld.adapter;

import androidx.annotation.NonNull;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import java.util.List;

public class RecordPagerAdapter extends FragmentPagerAdapter {
    public List<Fragment>fragmentList;//将集合传入
    String[]titles={"支出","收入"};
    public RecordPagerAdapter(@NonNull FragmentManager fm,List<Fragment>fragmentList) {
        super(fm);
        this.fragmentList=fragmentList;

    }

    @NonNull
    @Override
    public Fragment getItem(int position) {
        return fragmentList.get(position);//返回指定位置对应的fragment对象
    }

    @Override
    public int getCount() {
        return fragmentList.size();//返回fragment的长度
    }


    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];//返回指定位置对应的标题
    }
}
